package malitech.yadam.model.acquire;

import java.util.Properties;

import malitech.yadam.business.acquire.CopyJobStepRunner;

public class CopyJobStepParameters extends JobStepParameters
{

    private final String      sourceDirectoryFullPathPropertyName     = "SourceDirectoryFullPath";
    private final String      destinationRootDirectoryFullPathName    = "DestinationRootDirectoryFullPath";
    private final String      mustCreateSubdirectoryName              = "MustCreateSubdirectory";
    private final String      subdirectoryNamePatternName             = "SubdirectoryNamePattern";
    private final String      actualDestinationDirectoryTokenNameName = "ActualDestinationDirectoryTokenName";

    private String            sourceDirectoryFullPath;
    private String            destinationRootDirectoryFullPath;
    private boolean           mustCreateSubdirectory;
    private String            subdirectoryNamePattern;
    private String            actualDestinationDirectoryTokenName;
    private static final long serialVersionUID                        = 1L;

    public CopyJobStepParameters()
    {
        super();
        this.clazzName = "CopyJobStepParameters";
        this.jobStepRunner = new CopyJobStepRunner();
    }

    public CopyJobStepParameters(JobParameters parent)
    {
        super(parent);
        this.clazzName = "CopyJobStepParameters";
    }

    @Override
    public void load(final String prefix, final Properties properties)
    {
        super.load(prefix, properties);
        String keyName = prefix + "." + sourceDirectoryFullPathPropertyName;
        this.sourceDirectoryFullPath = properties.getProperty(keyName);

        keyName = prefix + "." + destinationRootDirectoryFullPathName;
        this.destinationRootDirectoryFullPath = properties.getProperty(keyName);

        keyName = prefix + "." + mustCreateSubdirectoryName;
        this.mustCreateSubdirectory = Boolean.parseBoolean(properties.getProperty(keyName));

        keyName = prefix + "." + subdirectoryNamePatternName;
        this.subdirectoryNamePattern = properties.getProperty(keyName);

        keyName = prefix + "." + actualDestinationDirectoryTokenNameName;
        this.actualDestinationDirectoryTokenName = properties.getProperty(keyName);
    }

    public void save(String prefix, Properties properties)
    {
        super.save(prefix, properties);
        String keyName = prefix + "." + sourceDirectoryFullPathPropertyName;
        properties.put(keyName, this.sourceDirectoryFullPath);

        keyName = prefix + "." + destinationRootDirectoryFullPathName;
        properties.put(keyName, this.destinationRootDirectoryFullPath);

        keyName = prefix + "." + mustCreateSubdirectoryName;
        properties.put(keyName, String.valueOf(this.mustCreateSubdirectory));

        keyName = prefix + "." + actualDestinationDirectoryTokenNameName;
        properties.put(keyName, this.actualDestinationDirectoryTokenName);

        keyName = prefix + "." + subdirectoryNamePatternName;
        properties.put(keyName, this.subdirectoryNamePattern);

    }

    public String getSourceDirectoryFullPath()
    {
        return sourceDirectoryFullPath;
    }

    public void setSourceDirectoryFullPath(String sourceDirectoryFullPath)
    {
        this.sourceDirectoryFullPath = sourceDirectoryFullPath;
    }

    public String getDestinationRootDirectoryFullPath()
    {
        return destinationRootDirectoryFullPath;
    }

    public void setDestinationRootDirectoryFullPath(String destinationRootDirectoryFullPath)
    {
        this.destinationRootDirectoryFullPath = destinationRootDirectoryFullPath;
    }

    public boolean isMustCreateSubdirectory()
    {
        return mustCreateSubdirectory;
    }

    public void setMustCreateSubdirectory(boolean mustCreateSubdirectory)
    {
        this.mustCreateSubdirectory = mustCreateSubdirectory;
    }

    public String getSubdirectoryNamePattern()
    {
        return subdirectoryNamePattern;
    }

    public void setSubdirectoryNamePattern(String subdirectoryNamePattern)
    {
        this.subdirectoryNamePattern = subdirectoryNamePattern;
    }

    public String getActualDestinationDirectoryTokenName()
    {
        return actualDestinationDirectoryTokenName;
    }

    public void setActualDestinationDirectoryTokenName(String actualDestinationDirectoryTokenName)
    {
        this.actualDestinationDirectoryTokenName = actualDestinationDirectoryTokenName;
    }

}
